package com.seven.service;

import java.util.Date;
import java.util.List;

import com.seven.dao.ProblemDao;
import com.seven.entity.Problem;

//问题业务类
public class ProblemService {
	ProblemDao problemDao = new ProblemDao();
	
	/**
	 * 添加问题
	 */
	public int addProblem(Problem problem) {
		return problemDao.addProblem(problem);
		
	}
	
	/**
	 * 删除问题
	 */
	public int deleteProblem(Problem problem) {
		return problemDao.deleteProblem(problem);
		
	}
	
	/**
	 * 传值需求:传问题id和审核状态
	 * 更新问题的审核状态
	 */
	public int updatePromblem(Problem problem) {
		
		int problem_isauditor = problem.getProblem_isauditor();
		int problem_id = problem.getProblem_id();
		System.out.println(problem+"111111111111111111111111");
		List<Problem> list = problemDao.selectByProblem_id(problem);
		Problem problem2 = list.get(0);
		System.out.println(problem2+"22222222222222222222222222222");
		
		String problem_addcontent = problem2.getProblem_addcontent();
		String problem_address = problem2.getProblem_address();
		String problem_bickunm = problem2.getProblem_bickunm();
		String problem_content = problem2.getProblem_content();
		int problem_ispass = problem2.getProblem_ispass();
		String problem_picture = problem2.getProblem_picture();
		String problem_picture2 = problem2.getProblem_picture2();
		Date problem_time = problem2.getProblem_time();
		String problem_title = problem2.getProblem_title();
		int users_id = problem2.getUsers_id();
		int worker_id = problem2.getWorker_id();
		
		Problem problem3 = new Problem();
		problem3.setProblem_addcontent(problem_addcontent);
		problem3.setProblem_address(problem_address);
		problem3.setProblem_bickunm(problem_bickunm);
		problem3.setProblem_content(problem_content);
		problem3.setProblem_id(problem_id);
		problem3.setProblem_isauditor(problem_isauditor);
		problem3.setProblem_ispass(problem_ispass);
		problem3.setProblem_picture(problem_picture);
		problem3.setProblem_picture2(problem_picture2);
		problem3.setProblem_time(problem_time);
		problem3.setProblem_title(problem_title);
		problem3.setUsers_id(users_id);
		problem3.setWorker_id(worker_id);
		System.out.println(problem3+"333333333333333333333");
		
		int n = problemDao.updatePromblem(problem3);
		
		return n;
	}
	
	/**
	 * 传值需求:传问题id和处理状态
	 * 更新问题的处理状态
	 */
	public int updatePromblem2(Problem problem) {
		
		int problem_ispass = problem.getProblem_ispass();
		System.out.println("xxxxxxxxxxxxxxxxxxxx"+problem_ispass);
		int problem_id = problem.getProblem_id();
		System.out.println(problem+"111111111111111111111111");
		List<Problem> list = problemDao.selectByProblem_id(problem);
		Problem problem2 = list.get(0);
		System.out.println(problem2+"22222222222222222222222222222");
		
		String problem_addcontent = problem2.getProblem_addcontent();
		String problem_address = problem2.getProblem_address();
		String problem_bickunm = problem2.getProblem_bickunm();
		String problem_content = problem2.getProblem_content();
		int problem_isauditor = problem2.getProblem_isauditor();
		String problem_picture = problem2.getProblem_picture();
		String problem_picture2 = problem2.getProblem_picture2();
		Date problem_time = problem2.getProblem_time();
		String problem_title = problem2.getProblem_title();
		int users_id = problem2.getUsers_id();
		int worker_id = problem2.getWorker_id();
		
		Problem problem3 = new Problem();
		problem3.setProblem_addcontent(problem_addcontent);
		problem3.setProblem_address(problem_address);
		problem3.setProblem_bickunm(problem_bickunm);
		problem3.setProblem_content(problem_content);
		problem3.setProblem_id(problem_id);
		problem3.setProblem_isauditor(problem_isauditor);
		problem3.setProblem_ispass(problem_ispass);
		problem3.setProblem_picture(problem_picture);
		problem3.setProblem_picture2(problem_picture2);
		problem3.setProblem_time(problem_time);
		problem3.setProblem_title(problem_title);
		problem3.setUsers_id(users_id);
		problem3.setWorker_id(worker_id);
		System.out.println(problem3+"333333333333333333333");
		
		int n = problemDao.updatePromblem(problem3);
		
		return n;
	}
	
	/**
	 * 传值需求:传问题id
	 * 改变问题状态为已处理
	 */
	public int updatePromblemToIspass(Problem problem) {
		
		int problem_id = problem.getProblem_id();
		
		List<Problem> list = problemDao.selectByProblem_id(problem);
		Problem problem2 = list.get(0);
		
		String problem_addcontent = problem2.getProblem_addcontent();
		String problem_address = problem2.getProblem_address();
		String problem_bickunm = problem2.getProblem_bickunm();
		String problem_content = problem2.getProblem_content();
		int problem_isauditor = problem2.getProblem_isauditor();
		int problem_ispass = 1;
		String problem_picture = problem2.getProblem_picture();
		String problem_picture2 = problem2.getProblem_picture2();
		Date problem_time = problem2.getProblem_time();
		String problem_title = problem2.getProblem_title();
		int users_id = problem2.getUsers_id();
		int worker_id = problem2.getWorker_id();
		
		Problem problem3 = new Problem();
		problem3.setProblem_addcontent(problem_addcontent);
		problem3.setProblem_address(problem_address);
		problem3.setProblem_bickunm(problem_bickunm);
		problem3.setProblem_content(problem_content);
		problem3.setProblem_id(problem_id);
		problem3.setProblem_isauditor(problem_isauditor);
		problem3.setProblem_ispass(problem_ispass);
		problem3.setProblem_picture(problem_picture);
		problem3.setProblem_picture2(problem_picture2);
		problem3.setProblem_time(problem_time);
		problem3.setProblem_title(problem_title);
		problem3.setUsers_id(users_id);
		problem3.setWorker_id(worker_id);
		
		int n = problemDao.updatePromblem(problem3);
		
		return n ;
		
	}
	
	/**
	 * 传值需求:传问题id和员工id
	 * 指派员工
	 */
	public int ProblemSetWorkerId(Problem problem) {
		return problemDao.setWorkerid(problem);
		
		
	}
	
	
	
	/**
	 * 查询所有问题
	 */
	public List<Problem> selectAllProblem() {
		return problemDao.selectAllProblem();
		
	}
	
	/**
	 * 通过id查询问题
	 */
	public List<Problem> selectByProblem_id(Problem problem) {
		return problemDao.selectByProblem_id(problem);
		
	}
	
	/**
	 * 通过用户id查询问题
	 */
	public List<Problem> selectByUsers_id(Problem problem) {
		return problemDao.selectByUsers_id(problem);
		
	}
	
	/**
	 * 通过员工id查询问题
	 */
	public List<Problem> selectByWorker_id(Problem problem) {
		return problemDao.selectByWorker_id(problem);
		
	}
	
	/**
	 * 查询出所有未审核的问题
	 */
	public List<Problem> selectByproblem_isauditor0() {
		return problemDao.selectByproblem_isauditor0();
		
	}
	
	/**
	 * 查询出所有审核未通过的问题
	 */
	public List<Problem> selectByproblem_isauditor_1() {
		return problemDao.selectByproblem_isauditor_1();
		
	}
	
	/**
	 * 查询出所有已审核的问题
	 */
	public List<Problem> selectByproblem_isauditor1() {
		return problemDao.selectByproblem_isauditor1();
		
	}
	
	/**
	 * 查询出所有未处理的问题
	 */
	public List<Problem> selectByproblem_ispass_1() {
		return problemDao.selectByproblem_ispass_1();
		
	}
	
	/**
	 * 查询出所有处理中的问题
	 */
	public List<Problem> selectByproblem_ispass0() {
		return problemDao.selectByproblem_ispass0();
		
	}
	
	/**
	 * 查询出所有已处理的问题
	 */
	public List<Problem> selectByproblem_ispass1() {
		return problemDao.selectByproblem_ispass1();
		
	}
}
